package com.example.thirdannotation.y2024.condition;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Set;

/**
 * 自定义逻辑，返回需要导入的组件
 */
public class MyImportSelector implements ImportSelector {

    /**
     * @param annotationMetadata： 当前标注@Import注解的类的 所有注解 信息
     * @return: 将返回的全类名的类，导入到容器中作为一个bean
     */
    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {
        Set<String> annotationTypes = annotationMetadata.getAnnotationTypes();
        for (String annotationType : annotationTypes) {
            System.out.println("annotationType-->"+annotationType);
        }
        return new String[]{"com.example.thirdannotation.y2024.bean.Red","com.example.thirdannotation.y2024.bean.Blue"};
    }
}
